<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>员工档案管理</title>
  <#assign base=request.contextPath  />
    <base id="basePath" href="${base}">

    <base id="basePath" href="${base}">
    <link rel="stylesheet" href="${base}/css/demo.css" type="text/css">
    <link rel="stylesheet" href="${base}/css/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="${base}/js/zhang.js"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery.ztree.excheck.js"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery.ztree.exedit.js"></script>
    <link rel="stylesheet" href="${base}/js/layui/css/layui.css" media="all">
    <script type="text/javascript" src="${base}/js/zhang.js"></script>
    <style type="text/css">
        form{
            padding: 20px;
        }
        .layui-btn-radius{
            border-radius: 5px;
        }
    </style>
</head>

<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>员工档案管理</legend>
</fieldset>
<div class="demoTable"style="padding:15px;">
    <button class="layui-btn layui-btn-radius" id="btn2" data-method="offset" type="button" style="background-color: #0092EF;">添加员工档案</button>
    <div class="layui-inline layui-form" style="float:right;">
        <div class="layui-input-inline">
            <select name="interest"  id="sech"  lay-search="">
                <option value="">请选择要搜索的列</option>
                <option value="name">姓名</option>
                <option value="age">年龄</option>
                <option value="address">户口所在地</option>
                <option value="workNumber">暂定工号</option>
                <option value="workingYears">工龄</option>
                <option value="dept">部门</option>
                <option value="postz">职务</option>
                <option value="phone">电话</option>
                <option value="idNumber">身份证号</option>
                <option value="marriage">婚否</option>
                <option value="nation">民族</option>
                <option value="education">学历</option>
                <option value="graduation">毕业院校</option>
                <option value="major">专业</option>
                <option value="trainingExperience">培训经历</option>
                <option value="obtainCertificate">获得证书</option>
                <option value="numberOfSigns">合同签订次数</option>
                <option value="presentAddress">现住址</option>
                <option value="urgent">紧急联系人/电话</option>
                <option value="accountOpening">开户行银行</option>
                <option value="movement">异动</option>
                <option value="remarks">渠道</option>


            </select>
        </div>

        <div class="layui-inline">
            <input class="layui-input" name="id" id="demoReload" autocomplete="off">
        </div>
        <button class="layui-btn layui-btn-radius" id="btn1" data-type="reload" style="background-color: #0092EF;">搜索</button>
    </div>
</div>
<table class="layui-hide" id="test"  lay-filter="test"></table>

<script type="text/html" id="barDemo">
    <i class="layui-icon layui-icon-edit" lay-event="edit" style="font-size: 20px;"></i>&nbsp;&nbsp;&nbsp;
    <i class="layui-icon layui-icon-delete layui-btn-xs" lay-event="del"  href="javascript:void(0)"  onclick="onDelete('{{d.id}}')"  style="font-size: 20px;" ></i>
</script>

<script src="${base}/js/layui/layui.js" charset="utf-8"></script>

<script src="${base}/js/jquery.min.js"></script>
<script>
    layui.use(['form', 'layedit', 'laydate','table'], function(){
        var form = layui.form
                ,$ = layui.jquery
                ,layer = layui.layer
                ,layedit = layui.layedit
                ,laydate = layui.laydate
                ,table = layui.table;

        table.render({
            elem: '#test'
            ,url:'${base}/employeeFile/select'
            ,title: '用户数据表'
            ,totalRow: true
            ,cellMinWidth:100
            ,toolbar: '#toolbarDemo'
            ,defaultToolbar: ['filter', 'print', 'exports']
            ,height:500
            ,cols:[[
                {field:'id', title: 'ID',templet:function(val){
                        return val.LAY_INDEX
                    },width:70, field: true,align:'center'}
                ,{field:'name', title: '姓名', width: 100,align:'center'}
                ,{field:'sex', title: '性别',align: 'center',align:'center'}
                ,{field:'workNumber', title: '工号', width: 120,align:'center'}
                ,{field:'dept', title: '部门', width: 100,align:'center'}
                ,{field:'age', title: '年龄', width: 100,align:'center'}
                ,{field:'nation', title: '民族', width: 100,align:'center'}
                ,{field:'birth', title: '出生日期', templet:function(val){
                        return DateFormat(val.birth);
                    },width: 150,align:'center'}
                ,{field:'idNumber', title: '身份证号', width: 200,align:'center'}
                ,{field:'marriage', title: '婚否', width: 100,align:'center'}
                ,{field:'phone', title: '联系电话', width: 130,align:'center'}
                ,{field:'urgent', title: '紧急联系人/电话', width: 100,align:'center'}
                ,{field:'address', title: '户口所在地', width: 100,align:'center'}
                ,{field:'presentAddress', title: '现住址', width: 100,align:'center'}
                ,{field:'education', title: '学历', width: 100,align:'center'}
                ,{field:'graduation', title: '毕业院校', width: 100,align:'center'}
                ,{field:'major', title: '专业', width: 100,align:'center'}
                ,{field:'trainingExperience', title: '培训经历', width: 100,align:'center'}
                ,{field:'obtainCertificate', title: '获得证书', width: 100,align:'center'}
                ,{field:'dateEntry', title: '入职日期', templet:function(val){
                        return DateFormat(val.dateEntry);
                    },width: '150',align:'center'}
                ,{field:'signing', title: '合同签订日期', templet:function(val){
                        return DateFormat(val.signing);
                    }, width: 100,align:'center'}
                ,{field:'probationPeriod', title: '试用期截止时间', templet:function(val){
                        return DateFormat(val.probationPeriod);
                    }, width: 150,align:'center'}
                ,{field:'expirationDate', title: '合同到期日期', templet:function(val){
                        return DateFormat(val.expirationDate);
                    }, width: 150,align:'center'}
                ,{field:'numberOfSigns', title: '合同签订次数', width: 100,align:'center'}
                ,{field:'workingYears', title: '工龄', width: 100,align:'center'}
                ,{field:'postz', title: '职务', width: 100,align:'center'}
                ,{field:'insurance', title: '本公司参保时间', templet:function(val){
                        return DateFormat(val.insurance);
                    }, width: 150,align:'center'}
                ,{field:'accountOpening', title: '开户行银行', width: 100,align:'center'}
                ,{field:'bankNumber', title: '银行卡号', width: 100,align:'center'}
                ,{field:'movement', title: '异动', width: 100,align:'center'}
                ,{field:'remarks', title: '备注', width: 100,align:'center'}
                ,{field:'channel', title: '渠道', width: 100,align:'center'}



                //,{field:'leaveDate', title: '离职日期', templet:function(val){
                //                                           return DateFormat(val.leaveDate);
                //                                          },width: '150',align:'center'}
                //,{field:'post', title: '岗位', width: '150',align:'center'}
                // ,{field:'medicalRecord', title: '病历史', width: '200',align:'center'}
                //,{field:'healthStatus', title: '健康状态', width: '130',align:'center'}
                //,{field:'state', title: '工作状态', width: '120',align:'center'}
                ,{field: 'right', title:'操作', toolbar: '#barDemo', width: '130',align:'center'}
            ]]
            ,id:'testReload'
            ,page: {
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                ,theme: '#0092EF'

            }
            ,done: function(res, curr, count){
                this.where={};
            }
        });
        $('#btn1').on('click', function(){
            var sechLin=$("#sech").val();
            var whereData={};
        });
        var active = {
            offset: function(othis){
                var type = othis.data('type')
                        ,text = othis.text();
                layer.open({
                    type: 2,

                    title: '添加员工档案',
                    offset: 't',
                    area:['720px','500px'],
                    shadeClose:false ,
                    content: '${base}/employeeFile/employee_add',

                });
            }
        };
        $('#btn2').on('click', function(){
            var othis = $(this), method = othis.data('method');
            active[method] ? active[method].call(this, othis) : '';
        });






//编辑弹出层
        table.on('tool(test)', function(obj){
            var layEvent = obj.event;
            if(layEvent=="edit"){
                var data = obj.data;
                //示范一个公告层
                layer.open({
                    type: 2,
                    title: '员工档案修改',
                    offset: 't',
                    shadeClose:false ,
                    area:['720px','500px'],
                    content: '${base}/employeeFile/employee_edit',
                    success: function (layero, index) {
                        var iframeWin = window[layero.find
                        ('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                        //暂定工号
                        iframeWin.$("#workNumber").val(data.workNumber)
                        //工龄
                        iframeWin.$("#workingYears").val(data.workingYears)
                        //姓名
                        iframeWin.$("#name").val(data.name)
                        //年龄
                        iframeWin.$("#age").val(data.age)
                        //户口所在地
                        iframeWin.$("#address").val(data.address)
                        //联系方式
                        iframeWin.$("#phone").val(data.phone)
                        //身份证
                        iframeWin.$("#idNumber").val(data.idNumber)
                        //出生日期
                        iframeWin.$("#date2").val(DateFormat(data.birth))
                        //入职日期
                        iframeWin.$("#date").val(DateFormat(data.dateEntry))
                        //部门
                        iframeWin.$("#dept").val(data.dept)
                        //职务
                        iframeWin.$("#postz").val(data.postz)
                        //婚否
                        iframeWin.$("#marriage").val(data.marriage)
                        //民族
                        iframeWin.$("#nation").val(data.nation)
                        //学历
                        iframeWin.$("#education").val(data.education)
                        //毕业院校
                        iframeWin.$("#graduation").val(data.graduation)
                        //专业
                        iframeWin.$("#major").val(data.major)
                        //培训经历
                        iframeWin.$("#trainingExperience").val(data.trainingExperience)
                        //获得证书
                        iframeWin.$("#obtainCertificate").val(data.obtainCertificate)
                        //试用期截止时间
                        iframeWin.$("#date3").val(DateFormat(data.probationPeriod))
                        //合同签订次数
                        iframeWin.$("#numberOfSigns").val(data.numberOfSigns)
                        //合同签订日期
                        iframeWin.$("#date4").val(DateFormat(data.signing))
                        //合同到期日期
                        iframeWin.$("#date5").val(DateFormat(data.expirationDate))
                        //现住址
                        iframeWin.$("#presentAddress").val(data.presentAddress)
                        //紧急联系人/电话
                        iframeWin.$("#urgent").val(data.urgent)
                        //开户银行
                        iframeWin.$("#accountOpening").val(data.accountOpening)
                        //银行卡号
                        iframeWin.$("#bankNumber").val(data.bankNumber)
                        //本公司参保时间
                        iframeWin.$("#date6").val(DateFormat(data.insurance))
                        //异动
                        iframeWin.$("#movement").val(data.movement)
                        //备注
                        iframeWin.$("#remarks").val(data.remarks)
                        //渠道
                        iframeWin.$("#channel").val(data.channel)






                        //iframeWin.$("#date1").val(DateFormat(data.leaveDate))
                        //iframeWin.$("#post").val(data.post)
                        //iframeWin.$("#medicalRecord").val(data.medicalRecord)
                        //iframeWin.$("#healthStatus").val(data.healthStatus)
                        //iframeWin.$("#state").val(data.state)
                        iframeWin.$("#id").val(data.id)
                        //渲染一下form表单
                        iframeWin.layui.form.render('select')
                        //单选框
                        if(data.sex=='男'){
                            iframeWin.$("#man").attr("checked",true)
                            var form = iframeWin.layui.form;
                            form.render('radio'); //更新全部
                        }else{
                            iframeWin.$("#wuman").attr("checked",true)
                            var form = iframeWin.layui.form;
                            form.render('radio'); //更新全部
                        }
                    }
                });
            }
        });

        layui.form.on('select()', function(data){
            $("#demoReload").val("")
        });
//实现搜索
        $('#btn1').on('click', function(){
            var sechLin=$("#sech").val();
            var sechData=$("#demoReload").val();

            var whereData={};
            whereData.lin=sechLin;
            whereData.data=Trim(sechData);
            whereData.page=1;
            whereData.limit=10;
            var table = layui.table;
            //表刷新方法
            table.reload('testReload', {
                url:'${base}/employeeFile/select'
                ,where: whereData //设定异步数据接口的额外参数
            });
        });
        String.prototype.trim = function() {
            return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
        }

//键盘事件
        $("body").bind("keydown",function(e){
            // 兼容FF和IE和Opera
            var theEvent = e || window.event;
            var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
            if (code == 13) {
                //回车执行查询
                $("#btn1").click();
            }
        });

    });





















    //删除
    function onDelete(id){
//提示是否删除这条数据
//data里边的customerId是需要和实体类里边的id是一样的,不然是传不过来参数的
        layer.confirm('真的要删除吗?',function(index){
            $.ajax({
                type:"POST",
                url:"${base}/employeeFile/deleteEmployeeFile",
                data:{"id":id},
                sync:false,
                success:function(data){
                    //alert("删除成功")
                    var table = layui.table;
                    //表刷新方法
                    table.reload('testReload', {
                        url:'${base}/employeeFile/select'
                        ,where: {} //设定异步数据接口的额外参数
                    });
                    //关闭删除是否删除的提示框
                    layer.close(index);
                }
            });
        });
    }






</script>

</body>
</html>